﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace EliteControls
{
	/// <summary>
	/// Interaction logic for ServiceRating.xaml
	/// </summary>
	public partial class Rating : UserControl, INotifyPropertyChanged
	{
		private string iconFile;
		private int value = 0;
		private List<Path> blips = new List<Path>();
		
		
		public Rating()
		{
			this.InitializeComponent();
			blips = new List<Path> {First,Second,Third,Forth,Fith,sixth,seventh,eighth,ninth};
		}
		
		public event PropertyChangedEventHandler PropertyChanged;
		
		public int Value
		{
			get
			{
				return this.value;
			}
			set
			{
				this.value = value;
				for(int i = 0; i< blips.Count; i++)					
				{
					if(this.value > i)
					{
						this.blips[i].Visibility = 	Visibility.Visible;
					} 
					else 
					{
						this.blips[i].Visibility = 	Visibility.Hidden;
					}
				}				
			}
		}
		
		public Brush PaintBrush
		{
			get
			{
				return this.First.Fill;				
			}
			set
			{
				
				foreach(Path blip in this.blips)
				{
					blip.Fill = value;
				}
				this.BackColour.Fill = value;
				this.MyGlow.Color = ((SolidColorBrush)value).Color;
				this.RaisePropertyChanged("Colour");
			}
		}
		
		public ImageSource IconFile
		{
			get
			{
                return this.Icon.Source;
			}
			set
			{
                this.Icon.Source = value;
			}
		}
		
		protected void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
		
		public string Colour
		{
			get
			{
				SolidColorBrush brush = this.PaintBrush as SolidColorBrush;				
				if(brush != null)
				{
					return brush.Color.ToString();
				} 
				else 
				{
					return "#FFFFFF";	
				}
			}
		}
	}
}